import { defineAsyncComponent } from 'vue';
import { Spin } from 'ant-design-vue';

/**
 * @description 路由懒加载
 * @param {Function} loader 组件加载函数
 * @returns 异步组件
 */
export const lazyLoad = (loader: () => Promise<any>) => {
  return defineAsyncComponent({
    loader,
    loadingComponent: Spin,
    delay: 200,
    timeout: 3000
  });
};